{extend name="public/base" /}{block name="style"}
<link href="__LIB__/fileinput/css/fileinput.min.css" rel="stylesheet" /> {/block} {block name="body"}
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('admin/index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li>
			<a href="{:url('index')}">消息管理</a>
		</li>
		<li><strong>消息发送</strong></li>
	</ol>
</div>
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			{include file="message/top"}
			<div class="ibox-content">
				<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('index')}">
					<span id="content" style="display: none;"></span>
					<input type="hidden" name="media_id" id="media_id"/>
					<input type="hidden"  id="temp_id" />
					<input type="hidden" id="message" name="message" />
					<div class="form-group">
						<label class="col-sm-2 control-label">选择分组：</label>
						<div class="input-group col-sm-2">
							<select name="label" class="form-control">
								<option value="">全部分组</option>
								{volist name="label" id='ad'}
								<option value="{$ad['id']}">{$ad['name']}</option>
								{/volist}
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">选择素材：</label>
						<div class="input-group col-sm-8">
							<button class="btn btn-primary" type="button" onclick="show_media()">点击选择素材</button>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">图文信息：</label>
						<div class="input-group col-sm-4">
							<span id="span_content"></span>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3">
							<button class="btn btn-danger" onclick="return checksub()" type="submit"><i class="fa fa-save"></i> 确定</button>&nbsp;&nbsp;
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<div class="modal-content" id="map-dialog" style="overflow-y:scroll;position:fixed;z-index:1000;background:#fff;left: 25%;top: 20%;right: 10%;display: none;bottom: 60px;">
				<div class="modal-header" style="padding: 5px;"><h4>请选择素材<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="$('#map-dialog').hide()">×</button></h4></div>
				<div class="modal-body" >
					  <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                            	<th width="5%"></th>
                                <th >标题</th>
                                <th >内容</th>
                             
                            </tr>
                        </thead>
                        <tbody id="list">
                        	{volist name="news" id='ad'}
                        	<tr>
                        		<td><input type="radio" data="{$ad.id}" name="scid" value="{$ad.media_id}" /></td>
                        		<td>{$ad.name}</td>
                        		<td id="content{$ad.id}"><?php echo json_decode($ad['content'],true)['content'] ?>
                        			</td>
                        	</tr>
                        	{/volist}
                        </tbody>
                    </table>
					<div class="modal-footer ">
							<a  class="btn btn-default" data-dismiss="modal" onclick="javascript:$('#map-dialog').hide()">取消</a><a onclick="setJW()"  class="btn btn-primary ">确认</a>
					</div>
				</div>
</div>
{/block} {block name="script"}
<script src="__LIB__/validate/jquery.validate.min.js"></script>
<script src="__LIB__/validate/messages_zh.min.js"></script>
<script src="__LIB__/validate/add_validate.min.js"></script>
<script src="__LIB__/fileinput/js/fileinput.min.js"></script>
<script src="__LIB__/fileinput/js/locales/zh.js"></script>
<script src="__LIB__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__LIB__/ueditor/ueditor.all.js" type="text/javascript"></script>
<script>
	//顶部导航
	$("#li-bar-image").addClass("active");
	upload_one('__IMG__/default.jpg');
	//编辑器
	var ueditor = UE.getEditor('content');
	function show_media(){
		$("#map-dialog").show();
	}
	function setJW(){
		var val=$('input:radio[name="scid"]:checked').val();
		 if(val==null){
                alert("请选择素材!");
                return false;
         }else{
         	$("#span_content").html($("#content").html());
         	$("#message").val($("#content").html());
         	$("#map-dialog").hide();
         	$("#media_id").val($("#temp_id").val());
         }
	}
	function checksub(){
		var id=$("#media_id").val();
		if(id==""){
			alert("请选择素材");
			return false;
		}
		
	}
	//顶部导航
	$(function() {
		$('input:radio[name="scid"]').click(function(){
			var id=$(this).attr("data");
			$("#temp_id").val($(this).val());
			$('#content').html($("#content"+id).html());
		})
		
	});
</script>
{/block}